<?
	global $table_edit, $config_xml_list, $config_xml_edit;
	$config_xml_list = "1111111111000000000000000000000000000000000000000000000";
	$config_xml_edit = "1111101111100100000000001101011111111111111111111111111";
	$table_edit = "config_view";
	include("ckeditor_config.php");	
switch($act){
	
	case "list_full":
	ShowListFull();	
	$tpl="list_full";
	break;
	
	case "add_full":
	case "edit_full":	
	ViewListFull();
	$title_page = "Chỉnh Sửa";
	$tpl="edit_full";
	break;

	
	case "addsm_full":
	case "editsm_full":
	ConfigFull();
	break;
	
	case "del":
	Del();
	break;
		
	case "changeactive":
	ChangeActive("active");
	break;
	
	case "dellist":
	DelList();
	break;
	
	case "show":
	ChangeShowList("active");
	break;
	
	case "hide":
	ChangeHideList("active");
	break;
		
	case "order":
	Order();
	break;
	
	default:
	ShowListFull();
	$title_page = "CMS - Sản phẩm";
	$tpl="list_full";
		
//	case "edit":	
//	Edit();
//	$title_page = "Chỉnh Sửa";
//	$tpl="edit";
//	break;
//	
//	case "add":	
//	$title_page = "Thêm";
//	$tpl="edit";
//	break;

//	case "addsm":
//	case "editsm":
//	Editsm();
//	break;
	
}
function ViewListFull()
{
	global $db;
	
	if(isset($_GET['id']))
	{
		$id=$_GET['id'];
		$sql = "select * from config_view where id = ".$id;
		$element = $db->getRow($sql);
		
		ViewList($element['alias'], $id);	
	}
}

function ViewList($table_edit_config, $id)
{
	global $db, $arr, $elements, $values, $db_name;
	
	$sql = "select column_name, data_type from information_schema.columns where table_name='".$table_edit_config."' AND table_schema ='".$db_name."'";
	
	$arr = $db->getAll($sql);
	
	$elements = ShowListArr($table_edit_config);
	
	if(isset($id))
	{
		$sql = "select * from config_view where active = 1 and id = '".$id."'";
	//echo $sql;
		$values = $db->getRow($sql);
	//print_r($values);
	}
}
function ConfigFull()
{
	global $db,$act, $FullUrl, $table_edit;	
		
	$arr = NULL;
	
	$arr = ArrPostClean($arr, 'alias');
	
	$arr = ArrPostClean($arr, 'values');
	$arr = ArrPostClean($arr, 'type');
		
	if ($act=="addsm_full")
	{
		// Xử lý Image
		$postId = vaInsert($table_edit,$arr);
		$msg="Add successfully";				
	}
	else
	{
		// Xử lý Image
		$id=$_POST['id'];
		vaUpdate($table_edit, $arr,' id='.$id);	
		$msg="Đã Edit successfully";	
	}
	
	$msg="Add successfully";
	$_SESSION['mess'] = $msg;
	$page="admin-pro.html?do=".$table_edit. (isset($_GET['page'])?'&page='.$_GET['page']:'');
	page_transfer2($page);	
}
?>